//
//  WJBaseLable.m
//  WJBSApp
//
//  Created by dllo on 16/7/13.
//  Copyright © 2016年 王景伟. All rights reserved.
//
// 白色的Label;
#import "WJBaseLable.h"

@interface WJBaseLable ()
@property (nonatomic, retain) UIColor *dayBgColor;
@property (nonatomic, retain) UIColor *nightBgColor;
@property (nonatomic, retain) UIColor *dayTextColor;
@property (nonatomic, retain) UIColor *nightTextColor;
@end

@implementation WJBaseLable

- (instancetype)initWithFrame:(CGRect)frame dayBgColor:(UIColor *)dayBgColor nightBgColor:(UIColor *)nightBgColor dayTextColor:(UIColor *)dayTextColor nightTextColor:(UIColor *)nightTextColor {
    self = [super initWithFrame:frame];

    self.dayBgColor = dayBgColor;
    self.nightBgColor = nightBgColor;
    self.dayTextColor = dayTextColor;
    self.nightTextColor = nightTextColor;
    
    [self changeColor];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor) name:@"changeColor" object:nil];
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    self.nightBgColor = FORBLACKCOLOR;
    self.nightTextColor = BSWhiteColor;
    self.dayBgColor = BSWhiteColor;
    self.dayTextColor = BSBlackColor;
    [self changeColor];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor) name:@"changeColor" object:nil];
    return self;
}


- (void)changeColor {
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"Mode"] isEqualToString:@"night"]) {
        if (self.nightBgColor) self.backgroundColor = self.nightBgColor;
        if (self.nightTextColor) self.textColor = self.nightTextColor;
    }else{
        if (self.dayBgColor) self.backgroundColor = self.dayBgColor;
        if (self.dayTextColor) self.textColor = self.dayTextColor;
    }
}

// 销毁观察者
- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
